package Week.w152;

import org.junit.Test;

import java.util.*;
import java.util.stream.Collectors;
public class Solution02 {
    public int dietPlanPerformance(int[] calories, int k, int lower, int upper) {

        if(calories==null||calories.length<=0){
            return 0;
        }
        int god=0;
        int bad=0;
        for(int i=0;i<calories.length;i++){
            int sum=0;
            if(i+k>calories.length){
                break;
            }
            for(int j=i;j<i+k&&j<calories.length;j++){
                sum+=calories[j];
            }
            if(sum<lower){
                bad++;
            }else  if(sum>upper){
                god++;
            }
        }

       return god-bad;

    }

    @Test
    public void test(){
        /**
         *
         * [6,13,8,7,10,1,12,11]
         * 6
         * 5
         * 37
         *
         * 答案3
         */
    }
}
